const fs = require('fs');

let  readJson = (url)=>{
 let res =   fs.readFileSync(url,'utf-8');
 return res
}
/**
 * url 指定路径名字
 * data json字符串·
 * callback 回调函数
 */
let  writeJson = (url, data)=>{
	return new Promise((res,rej)=>{
		fs.writeFile(url, data,{ encoding:'utf8' },(err) => {
		    if (err) {
		      rej(err)
			  return
		    }
			res()
		  });
	})
   }

let util = {
    readJson,writeJson
}

module.exports = util;